//插入模块
var gulp = require("gulp");
var livereload = require("gulp-livereload");
var webserver = require("gulp-webserver");
var sass = require("gulp-ruby-sass");

// 任务一  刷新
gulp.task("shuaxin",function(){
    return gulp.src("dest").pipe(webserver({
        livereload:true,
        open:true
    }))
});

//任务二  移动
gulp.task("move",function(){
    return gulp.src("src/**/*.{html,js,css,jpg,png,gif}").pipe(gulp.dest("dest"))
});
//任务三 sass编译
gulp.task("sass",function(){
    return sass("src/css/*.scss",{style:"compressed"})
        .on("error",function(err,data){
            if(err){
                console.log(err)
            }else {
                console.log(data)
            }
        })
        .pipe(gulp.dest("dest/css"))
});
//任务三 监听
gulp.task("watch",function(){
    //移动
    gulp.watch("src/**/*.{html,js,css,jpg,png,gif}",["move"])

    //编译
    gulp.watch("src/css/*.scss",["sass"])

});
//默认事件
gulp.task("default",["move","sass","watch","shuaxin"])